package p13.p1318;

public class StringPaiXu {
    public static void main(String[] args) {
        String s = "dacefgb";
        char[] arr = s.toCharArray();

        printCharArrey(arr);//遍历
        paixu(arr);//排序
        System.out.println();
        printCharArrey(arr);//排序后
        System.out.println(String.valueOf(arr));


    }

    //字符串转数组

    //数字遍历
    public static void printArrey(int arr[]) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            System.out.printf(" ");
        }
    }

    //字符遍历
    public static void printCharArrey(char arr[]) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            System.out.printf(" ");
        }
    }

    //字符冒泡排序
    //排序
    public static void paixu(char aee[]) {
        for (int a = 0;a<aee.length-1;a++) {
            for (int i = 0; i < aee.length - 1; i++) {
                if (aee[i] > aee[i + 1]) {
                    char temp = aee[i];
                    aee[i] = aee[i + 1];
                    aee[i + 1] = temp;
                    //*System.out.println(aee[i]);*//*
                }
            }
        }
    }


}
